<?php
/* @var $this PotentialCustomersListController */
/* @var $model PotentialCustomersList */

$this->breadcrumbs=array(
	Yii::t('base','Potential Customers Lists')=>array('index'),
	Yii::t('base','Manage'),
);
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#potential-customers-list-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});

$('#submitBtn').click(function(){
	var activity=$('#activity option:selected').val();
	var customers_list_id=$('#customers_list_id').val();
	$.ajax({
		type: 'POST',
		url:'".Yii::app()->createUrl("/potentialCustomersList/Import")."',
		data: {'activity': activity,'customers_list_id':customers_list_id},
		success: function(data){
			alert('错误信息:'+data);
		}
		});
});
");
?>

<h1><?php echo Yii::t('base','Manage Potential Customers Lists')?></h1>

<?php echo Yii::t('base','<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>')?>

<?php echo CHtml::link(Yii::t('base','Advanced Search'),'#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->
<a class="btn btn-small create" title="<?php echo Yii::t('base','Create');echo Yii::t('base','Customers List');?>" href="<?php echo Yii::app()->request->baseUrl; ?>/potentialCustomersList/create"><?php echo Yii::t('base','Create');echo Yii::t('base','Customers List');?></a>
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'potential-customers-list-grid',
	'dataProvider'=>$model->search(),
	'itemsCssClass'=>'responsive table table-striped table-bordered',
	'pager'=>array('class'=>'CLinkPager','hiddenPageCssClass'=>'','firstPageCssClass'=>'first paginate_button','htmlOptions'=>array('class'=>'dataTables_paginate paging_full_numbers"'),'header'=>""),
	'pagerCssClass'=>'pagination',
	'cssFile'=>false,
	'template'=>'{items}{summary}{pager}',
	'columns'=>array(
		//'potential_customers_list_id',
		array('name'=>'potential_customers_list_id','headerHtmlOptions'=>array('style'=>'width:30%')),
		//'potential_customers_list_name',
		array('name'=>'potential_customers_list_name','headerHtmlOptions'=>array('style'=>'width:30%')),
		array(
			'class'=>'CButtonColumn',
			'header'=>Yii::t('base','Operate'),
			'viewButtonImageUrl'=>array('class'=>'gicon-edit'),
			'viewButtonOptions'=>array('class'=>'btn btn-small'),
			'updateButtonImageUrl'=>array('class'=>'gicon-edit'),
			'updateButtonOptions'=>array('class'=>'btn btn-small'),
			'deleteButtonImageUrl'=>array('class'=>'gicon-edit'),
			'deleteButtonOptions'=>array('class'=>'btn btn-inverse btn-small'),
			'template'=>'{view}{update}{delete}{import}{Export}',
			'buttons'=>array(
					'import'=>array(
							'label'=>Yii::t('base','import'),
							'url'=> '"javascript:box(\"".$data->potential_customers_list_id."\",\"".$data->potential_customers_list_name."\");"',
							'options' => array('class'=>'btn btn-small',
							),
					),
					'Export'=>array(
							'label'=>Yii::t('base','Export'),
							'url'=>'yii::app()->createUrl("/potentialCustomersList/export",array("id"=>$data->potential_customers_list_id)) ',
							'options' => array('class'=>'btn btn-small',
							),
					),
			),
		),
	),
)); ?>
<?php 
	$rs = PotentialCustomersList::model()->getActivityList();
	$rsult = PotentialCustomersList::model()->getCustomersList();
	$id = $_POST['id'];
?>

<!-- 弹出窗口 -->
<div id="myModal" style="display: none;">
	<form id="upForm" name="upForm" method="post"> 
		<table>
			<tr>
				<td><?php echo Yii::t('base', 'Select a list');?>:</td>
				<td>
					<select id="activity" name="activity">
					<?php 
						for ($i=0; $i<count($rs); $i++){
					?>
						<option value="<?php echo $rs[$i][activity_code];?>"><?php echo $rs[$i][title];?></option>
					<?php } ?>
					</select>
				</td>
			</tr>
			
			<tr>
				<td><?php echo Yii::t('base', 'Importing Customer List');?>:</td>
				<td>
					<input type="text" name="namee" id="namee" disabled="false" style="width: 220px;"/>
					<input type="hidden" name="customers_list_id" id="customers_list_id" />
				</td>
			</tr> 
			<tr>
				<td><input type="button" name="submitBtn" id="submitBtn" value="<?php echo Yii::t('base', 'import');?>" /> </td>
			</tr>
		</table>
	</form>  
		<span id="upload_repairinfo_success" style="color:blue;"></span> 
</div>
<!-- 弹出窗口 -->
<script type="text/javascript">
function box(id,name){
			$("#namee").attr("value",name);
			$("#customers_list_id").attr("value",id);
			/*
			$.post("<?php //echo Yii::app()->createUrl('potentialCustomersList/admin'); ?>",{'id':id}, 
					function (data) {
				 });
			 */
			$.fancybox.open({
				href : '#myModal',
				type : 'inline',
				maxWidth	: 500,
				maxHeight	: 212,
				fitToView	: false,
				width		: '500',
				height		: '212',
				autoSize	: false,
				openEffect	: 'none',
				closeBtn	: true,//正式发布时请将true,改为false,不显示关闭按钮
				closeClick	: false,
				helpers : {
					overlay : null,
				}
		});
}
</script>
